package ${package.Controller};

import org.springframework.web.bind.annotation.RequestMapping;

<#if restControllerStyle>
import org.springframework.web.bind.annotation.RestController;
<#else>
import org.springframework.stereotype.Controller;
</#if>
<#if superControllerClassPackage??>
import ${superControllerClassPackage};
</#if>

/**
 * <p>
 * ${table.comment!} 前端控制器
 * </p>
 *
 * @author ${author}
 * @since ${date}
 */
<#if restControllerStyle>
@RestController
<#else>
@Controller
</#if>
@RequestMapping("/admin/<#if package.ModuleName??>/${package.ModuleName}</#if>/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.entityPath}</#if>")
<#if swagger2>
@Api(tags = "${entity}", description = "${table.comment!}接口")
</#if>
<#if kotlin>
class ${table.controllerName}<#if superControllerClass??> : ${superControllerClass}()</#if>
<#else>
<#if superControllerClass??>
public class ${table.controllerName} extends ${superControllerClass} {
<#else>
public class ${table.controllerName} {
</#if>
 private static final Logger logger = LoggerFactory.getLogger(${table.controllerName}.class);

@Reference(version = "$ {dubbo.service.version}",
application = "$ {dubbo.application.id}",
retries = -1)
 @Autowired
 private ${entity}Service ${package.ModuleName}Service;

 @GetMapping("/page")
 @ApiOperation(value = "查询分页")
 public Object page(@RequestParam Map<String,Object> params) throws Exception {
  return ResponseUtil.ok(${package.ModuleName}Service.findMapByPageList(params));
 }

 @GetMapping("/load")
 @ApiOperation(value = "读取单个")
 public Object load(@RequestParam Map<String,String> params, @CurrentUser TmUser user) {
 return ResponseUtil.ok(${package.ModuleName}Service.getById(Long.parseLong(params.get("id"))));
}

 @PostMapping("/save")
 @ApiOperation(value = "保存信息")
 public Object save(@RequestBody ${entity} ${package.ModuleName},@CurrentUser TmUser user) throws Exception {
  ${package.ModuleName}Service.saveOrUpdate(${package.ModuleName});
  return ResponseUtil.ok("success");
}

 @PostMapping("/del")
 @ApiOperation(value = "删除")
 public Object del(@RequestBody ${entity} ${package.ModuleName}) throws Exception {
${package.ModuleName}Service.removeById(${package.ModuleName}.getId());
 return ResponseUtil.ok("success");
 }

@PostMapping("/export")
@ApiOperation(value = "导出excel")
public Object export(@RequestParam Map<String,Object> params) throws Exception {
return ResponseUtil.ok(${package.ModuleName}Service.findMapByList(params));
}
}
</#if>
